<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<script>
  var thsTitle = "交易须知与交易规则页面";
  var objName="content";
</script>
</head>
<body >
<!-- 正文开始 -->
<div title="交易须知与交易规则" style="padding:10px;">
<div class="searchForm"><form id="contentList_form">
	<input type="hidden" name="page"  value="1">
	<input type="hidden" name="rows"  value="10">
	<input type="hidden" name="objType"  value="${objType}">
	<input type="hidden" name="objId"  value="${objId}">
	<!-- 标题&nbsp;<input type="text" name="title" value="" /> 
	内容类型：
			<select name="contentType" >
			 <option value="">---请选择---</option>
			 <option value="报名须知">报名须知</option>
			 <option value="报价须知">报价须知</option>
			 <option value="交易规则">交易规则</option>
			 <option value="${ggname}">${ggname}</option>
			</select> 
	<a class="easyui-linkbutton"  iconCls="icon-search" onclick="contentListSearch();">查询</a>
	<a class="easyui-linkbutton"  iconCls="icon-no" onclick="clearFormById('contentList_form');">清空</a>-->
	<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen('报名须知');" title="增加报名须知">填写报名须知</a>
	<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen('报价须知');" title="增加报价须知">填写报价须知</a>
	<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen('交易规则');" title="增加交易规则">填写交易规则</a>
	<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen('${ggname}');" title="增加${ggname}">${ggname}</a>
</form></div>
<table id="contentList_table" class="info" cellspacing="1" cellpadding="0">
	<tr class='active' id="title2" >
		<th width='30%'>标题</th>
		<th width='10%'>内容类型</th>
		<th width='10%'>是否强制阅读</th>
		<th width='20%'>创建时间</th>
		<th width='30%' class='th_center'>操作</th>
	</tr>
</table>
<div id="contentList_page" class="page"></div>
<script type="text/template" id="contentList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=content_<?=rows[i].infoId?>>
			<td><?=rows[i].title?></td>
			<td><?=rows[i].contentType?></td>
			<td><?=rows[i].ifRead=='T'?'是':'否'?></td>
            <td><?=rows[i].createTime?></td>
			<td>
				<center><a class="mybutton"  onclick="editOpen('<?=rows[i].infoId?>');">修改</a> ||
				<a class="mybutton"  onclick="del('<?=rows[i].infoId?>');">删除</a></center>
			</td>
		</tr>
   <?}?>  		
</script>
<div class="easyui-dialog" id="add_window" title="增加交易须知与公告" closed="true" style="width:800px;height:400px;top:20px;">
<div class="searchForm"><form id="contentAddForm">
		<input type="hidden" name="objType"  value="${objType}">
		<input type="hidden" name="objId"  value="${objId}" />
		<input type="hidden" name="infoId" id="infoId" value="" />
		<center><a class="easyui-linkbutton"  iconCls="icon-reload" id="saveBtnFirst"  onclick="saveContent('contentAddForm');">保存</a></center>
		<table class="info" cellspacing="1" cellpadding="0"/>
		<tr><th>标题</th><td ><input type="text" name="title" id="title" size="45" value="" maxlength="200" required="true"  missingMessage="标题不能为空"  class="easyui-validatebox validatebox-text" 
			validtype="length[1,30]"	required="true"  missingMessage="请输入标题"  
				invalidMessage="最多可输入30中文字符"  title="标题最多可输入30中文字符"  /></td></tr>
		<tr><th>内容类型</th><td ><input type="text" name="contentType" id="contentType"  value="" style="border: 0px;" readonly="readonly" /></td></tr>
		<tr><th>是否强制阅读</th><td><input type="radio" name="ifRead" value="T" />是&nbsp;&nbsp;
			<input type="radio" name="ifRead" value="F" checked="checked" >否&nbsp;&nbsp;</td></tr>
		<tr><td colspan="2" ><textarea id="infoContent" name="infoContent" style="width:90%;height:400px;" class="easyui-validatebox validatebox-text" 
			required="true"  missingMessage="须知规则或公告内容不能为空"   title="须知规则或公告内容" ></textarea></td></tr>
		</table>
		<center><a class="easyui-linkbutton"  iconCls="icon-reload" id="saveBtnSecond" onclick="saveContent('contentAddForm');">保存</a></center>
		</form></div></div>
</div>
<!-- 正文结束 -->
<%//@ include file="/common/top.jsp" %>
</body>
</html>
<script>

//打开查看页面
function view(infoId){
	alert(infoId);
	getObj(objName,infoId);
}

//================新增与更新===================
//新增： 打开新增窗口
function addOPen(contentType){
    clearFormById("contentAddForm");
    $("#infoId").val("");
    editor.html("");//清空编辑器
    $("#contentType").val(contentType);
    $("#title").val('${objName}'+contentType);
	$("#add_window").dialog('open');
}

//打开更新页面
function editOpen(infoId){
    clearFormById("contentAddForm");
    editor.html("");//清空编辑器
	getObj(objName,infoId);
}

function getCallBack(flag,obj){
    if("T"==flag){
		loadData(obj,"contentAddForm");
		if(obj.infoContent != null && obj.infoContent != "")editor.html(obj.infoContent);//给编辑器赋初值
		$("#add_window").dialog('open');
	}else{
		alert("查询失败");
	}
}

function saveContent(formName){
	var infoId = $("#"+formName).find("input[name='infoId']").val();
	editor.sync(); //将编辑器中的内容设置到原来的textarea中
	if(infoId==""){
	    if(!$("#"+formName).form('validate')){
	    	return false;
		}
	    $("#saveBtnFirst").linkbutton("disable");
        $("#saveBtnSecond").linkbutton("disable");
		addSubmit('content',formName);
	}else{
		editSubmit('content',infoId,formName);
	}
}

function addCallBack(flag,msg,objName){
	$("#saveBtnFirst").linkbutton("enable");
    $("#saveBtnSecond").linkbutton("enable");
    if(flag=="T"){
		contentListSearch();
		$("#add_window").dialog('close');
	}else{
		alert(msg);
	}
}

function editCallBack(flag,objName){
     if(flag=="T"){
		contentListSearch();
		$("#add_window").dialog('close');
	}else{
		alert("更新失败！");
	}
}

//===================删除===================
function del(infoId){
    if(confirm("确定要删除吗？")){
		delSubmit(objName,infoId);
	}
}
//删除后回调方法
function delCallBack(flag,objName){
	if(flag=="T"){
		searchSubmit(objName,"contentList");
	}else{
		alert("删除失败！");
	}
}

//=================查询列表==================
function contentListSearch(){
   searchSubmit(objName,"contentList");
}


$(function(){
 loadKEditor('infoContent','100%','400px');
 searchSubmit(objName,"contentList");
});
</script>